<?php
	namespace AppBundle\Form\Type;
	use Symfony\Component\Form\AbstractType;
	use Symfony\Component\Form\FormBuilderInterface;
	use Symfony\Component\Form\Extension\Core\Type\SubmitType;
	use Symfony\Component\Form\Extension\Core\Type\TextType;
	use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
	use Symfony\Component\Form\Extension\Core\Type\CollectionType;
	use Symfony\Component\OptionsResolver\OptionsResolver;
	use AppBundle\Entity\Student;
	use AppBundle\Form\Type\MajorType;

	class StudentType extends AbstractType{
		public function buildForm(FormBuilderInterface $builder, array $options){
			$builder
				->add('name', TextType::class)
				->add('age', TextType::class)
				->add('addtime', DateTimeType::class, array('widget' => 'single_text'))
				->add('majors', CollectionType::class, array('entry_type' => MajorType::class, 'allow_add' => true, 'allow_delete' => true))
				->add("submit", SubmitType::class, array('label' => '提交'));
		}

		public function configureOptions(OptionsResolver $resolver){
			$resolver->setDefaults(array(
				'data_class' => 'AppBundle\Entity\Student',
			));
		}
	}